package com.drama.outtake.controller.vo;

import com.drama.outtake.domain.Order;
import com.drama.outtake.domain.ShopOfCart;
import com.drama.outtake.domain.enums.OrderStatus;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

/**
 * @Author : 李先均
 * @Date 2023/4/6 12:13
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class OrderVO {//TODO 选择就餐方式
    private ShopOfCart cart;
    private AddressVO address;
    private Double totalCost;
    private String remark;
    private Integer cutleryNumber;
    private LocalDateTime deliveryTime;
    private String sn;

    public Order convertToOrder() {
        return Order.builder()
                .status(OrderStatus.payed)
                .createTime(LocalDateTime.now())
                .deliverTime(this.getDeliveryTime())
                .packageFees(this.getCart().getAmountPackagePrice())
                .totalCost(this.getTotalCost())
                .remark(this.getRemark())
                .cutleryNumber(this.getCutleryNumber())
                .shopId(this.getCart().getShopId())
                .sn(this.getSn())
                .items(this.getCart().getCartItems())
                .deliveryFees(this.getCart().getAmountPrice() / 10)
                .userName(this.getAddress().getName())
                .userAd(this.getAddress().getAd())
                .userPhone(this.getAddress().getPhone())
                .userGender(this.getAddress().getGender())
                .build();
    }
}
